<?php
use Yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\widgets\LinkPager;
use yii\helpers\Url;
echo $this->render('_centernav');?>

<h1>系统消息</h1>
<table>
	<?php foreach($system as $k=>$v){?>
		<?php if($v['message_type'] == 1){?>
		<tr>
			<td><img src="http://files.bwphp.com/<?php echo $v['message_content']['user_thumb']?>" alt="" height='100px' width='150px'></td>
			<td><?php echo $v['message_content']['user_name']?>&nbsp;&nbsp;&nbsp;&nbsp;请求添加你为好友</td>
			<?php if($v['message_operation'] == 1){?>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value='已同意' disabled><?php echo $v['addtime']?></td>
			<?php }else if($v['message_operation'] == 2){?>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value='已拒绝' disabled><?php echo $v['addtime']?></td>
			<?php }else if($v['message_operation'] == 0){?>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value='同意' class='right' operation="<?php echo $v['message_id']?>" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" class='no' operation="<?php echo $v['message_id']?>" value='拒绝'>
			<?php echo $v['addtime']?></td>
			<?php }?>
		</tr>
		<?php }else if($v['message_type'] == 0){ ?>
		<tr>
			<td><font>系统提示</font></td>
			<td><?php echo $v->message_content?></td>
			<td><?php echo $v['addtime']?></td>
		</tr>
		
		<?php }?>
	<?php }?>
</table>





<?php echo LinkPager::widget([
	'pagination' => $pagination,
	'prevPageLabel'=>'上一页',
	'nextPageLabel'=>'下一页',
]);?>
<script>
	$(".right").click(function(){
		var message_id = $(this).attr('operation')
		$.ajax({
		   type: "POST",
		   url: "<?= Url::to(['center/operation'])?>",
		   data: "message_id="+message_id+'&message_operation=1',
		   success: function(msg){
			 if(msg == 1){
				alert('添加成功,该用户已在您的好友列表')
				location.reload();
			 }
		   }
		});
	})
	$(".no").click(function(){
		var message_id = $(this).attr('operation')
			var message_id = $(this).attr('operation')
		$.ajax({
		   type: "POST",
		   url: "<?= Url::to(['center/operation'])?>",
		   data: "message_id="+message_id+'&message_operation=2',
		   success: function(msg){
			 if(msg == 1){
				alert('您已拒绝该用户的请求')
				location.reload();
			 }
		   }
		});
	})
</script>